package cn.cstech.aijia.ui.base.utils;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import cn.cstech.aijia.R;


public class LoadingDialog extends Dialog {
	private Context mContext;
	private TextView msgView;
	public LoadingDialog(Context context, boolean cancelable,
						 OnCancelListener cancelListener) {
		super(context, cancelable, cancelListener);
		init(context);
	}

	public LoadingDialog(Context context, int theme) {
		super(context, theme);
		init(context);
	}

	public LoadingDialog(Context context) {
		super(context);
		init(context);
	}

	private void init(Context context){
		mContext = context;
		
		LayoutInflater mLayoutInflater = LayoutInflater.from(context);
		View view = mLayoutInflater.inflate(R.layout.loading_dialog, null);
		
//		getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); 
		setContentView(view);
		
		msgView = (TextView)view.findViewById(R.id.tv_msg);

		ImageView imageView = (ImageView) view.findViewById(R.id.iv_waiting);
        AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getBackground();
        animationDrawable.start();  
	}
	
	public void setDlgMessage(String message){
		if(!TextUtils.isEmpty(message)){
			msgView.setVisibility(View.VISIBLE);
			msgView.setText(message);
		}
	}
}
